import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA
 * Description：计时器
 * User：chenshu
 * Date：2023-11-08
 * Time：22:29
 */
public class Demo6 {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("这是一个任务");
            }
        }, 3000);
        while (true) {
            System.out.println("main");
            Thread.sleep(1000);
        }
    }
}
